<?php
define('ADMIN_USERNAME','melec'); 	// Admin Username
define('ADMIN_PASSWORD','xsw2XSW@');  	// Admin Password

// add more as an array
//$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array

////////// END OF DEFAULT CONFIG AREA /////////////////////////////////////////////////////////////

///////////////// Password protect ////////////////////////////////////////////////////////////////
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
           $_SERVER['PHP_AUTH_USER'] != ADMIN_USERNAME ||$_SERVER['PHP_AUTH_PW'] != ADMIN_PASSWORD) {
			Header("WWW-Authenticate: Basic realm=\"Memcache Login\"");
			Header("HTTP/1.0 401 Unauthorized");

			echo <<<EOB
				<html><body>
				<h1>Rejected!</h1>
				<big>Wrong Username or Password!</big>
				</body></html>
EOB;
			exit;
}

/////////// ENCRYPT FUNCTIONS /////////////////////////////////////////////////////////////////////
$oldpass	=	'';
$newpass	=	'';
if(isset($_POST['do'])){
	$oldpass	=	strip_tags($_POST['oldpass']);

	include '../addons/libs/3des.php';

	$crypt	=	new Crypt3DES;
	$encode	=	$crypt->encrypt($oldpass);
	//echo $encode.'<br />';
	//$decode	=	$crypt->decrypt($encode);
	//echo $decode.'<br />';

	$newpass	=	$encode;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>密码生成工具</title>
<style>
@charset "utf-8";
/** Reset something
----------------------------------*/
* { word-wrap:break-word; outline:none; }
body { background-color:#fff; color:#555555; font: 12px Arial, Helvetica, sans-serif; }
body, ul, dl, dd, p, h1, h2, h3, h4, h5, h6, form, fieldset { margin:0; padding:0; }
a { color:#2366A8; text-decoration:none; }
a:hover { text-decoration:underline; }
a img { border:none; }
table { border-collapse:collapse; border-spacing:0; }
input, textarea, select { background-color:#F9F9F9; border:1px solid #6699CC; line-height:1.3em; margin:5px 0; }
.txt{ padding:5px 0;}
.pt10{ padding-top:10px;}
.pb10{ padding-bottom:10px;}
.txt, select { vertical-align:middle; }
.txt:hover, .txt:focus, textarea:hover, textarea:focus { background-color:#F5F9FD; border-color:#0A5EA6; }
.radio, .checkbox { border:none; background:none; vertical-align:middle; }
button, .button { border:1px solid #3B7394; color:#002973; height:29px; cursor:pointer; margin:3px; padding:2px 8px; vertical-align:middle; }

#container,#container_s{ margin:0 auto; padding:9px 20px 20px; text-align:center; }
.infobox { clear:both; margin-bottom:10px; padding:30px; text-align:center; border-top:4px solid #DEEFFA; border-bottom:4px solid #DEEEFA; background:#F2F9FD; zoom:1; }
.infotitle1 { margin-bottom:10px; color:#09C; font-size:14px; font-weight:700; }
.infotitle2 { margin-bottom:10px; color:#090; font-size:14px; font-weight:700; }
.infotitle3 { margin-bottom:10px; color:#C00; font-size:14px; font-weight:700; }
.tableborder { border:#B5CFD9 solid 1px; empty-cells:show; text-align:left; margin-bottom:10px; width:100%; }
.tableborder td, .tableborder th { padding-left:5px; font-size:12px; }
.tableborder .tips { border-top:1px solid #BBDCF1; border-bottom:1px solid #BBDCF1; text-align:center; }
.tips ul { margin:5px 20px; text-align:left; }
.tips li { line-height:1.5em; }
.tableborder .border { background:url(../images/table_hb.gif) repeat-x 0 0; height:9px; font-size:0; overflow:hidden; }
.tableborder .header { background:url(../images/table_hb.gif) repeat-x 0 -9px; color:#0A5EA6; font-size:14px; padding-bottom:2px; line-height: 30px; }
.tableborder .label { background-color:#FDFEFF; height:1.5em; line-height:1.5em; }
.label th { border-bottom:1px solid #BBDCF1; }
.tableborder .cell { padding:2px; height:25px; line-height:25px; }
.cell td { border-bottom:1px solid #BBDCF1; }
.tableborder .altbg1 { background-color:#F1F5F8; }
.tableborder .altbg2 { background-color:#FFFFFF; }
.tableborder .footer { background-color:#FDFEFF; height:1.5em; line-height:1.5em; text-align:center; padding:2px; }
</style>

<body>

<div id="main" class="main" >
<div id="container_s">
<form method="post" action="">
	<table class="tableborder" width="100%">
		<tr class="cell">
			<td class="altbg1">加密前：</td>
			<td class="altbg2"><input type="text" class="txt" class="large bLeftRequire" name="oldpass" value="<?php echo $oldpass;?>" style="width:400px"></td>
		</tr>
		<tr class="cell">
			<td class="altbg1">加密后：</td>
			<td class="altbg2">
				<input type="text" class="txt" class="large bLeftRequire" name="newpass" value="<?php echo $newpass;?>" style="width:400px"></td>
		</tr>
		<tr>
			<td ></td>
			<td><input type="submit" name="do" value="生 成 密 码" class="button" /></td>
		</tr>
	</table>
</form>
</div>
</div>
</body>
</html>